fix: propagate the API run id to the tracker - #1327
Open
davidberenstein1957 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1327 +/- ##
==========================================
+ Coverage 91.43% 91.50% +0.06%
==========================================
Files 49 49
Lines 5057 5063 +6
==========================================
+ Hits 4624 4633 +9
+ Misses 433 430 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The tracker generated its own run_id and never picked up the one the API created, so API-backed runs persisted a local uuid (or the string "None") instead of the run id the server knows about. Create the API run in start(), where the output handler is already wired, and adopt its run id when there is one. run_id stays a plain writable attribute. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
davidberenstein1957
force-pushed
the
fix/api-run-id-never-propagates
branch
from
August 19, 2026 14:01
08cdabf to
0221c73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
EmissionsTracker.run_idis now a property backed by a locally generated uuid that returns the API run id as soon as one exists, and the API run is created instart()rather than on the first emission.Why
With
OutputMethod.APIenabled, the tracker readrun_idfromCodeCarbonAPIOutputat construction time, but that handler builds itsApiClientwithcreate_run_automatically=Falseand only creates the run lazily in_ensure_api_run. Nothing ever wrote the resulting id back, sotracker.run_idstayedNoneand_prepare_emissions_datarecorded the literal string"None"in every row.Consequences for users: CSV data could not be joined with the API data,
on_csv_write="update"matched on"None"and overwrote the previous run's row, and per-task / BOAMPS filenames all collided on..._None.csv.Creating the run in
start()(instead of only fixing the property) makes sure a single run has a single id everywhere, including rows persisted before the first API call. Failures there are logged and fall back to the local uuid, so an unreachable API no longer prevents tracking.Verified
tests/test_emissions_tracker.py::TestCarbonTracker::test_run_id_with_api_output_is_never_noneassertstracker.run_idis notNoneand that the run id written toemissions.csvmatches the API run id. It fails onmasterand passes with this change.uv run pytest tests/test_emissions_tracker.py tests/output_methods tests/test_tracking_inference.py tests/test_api_call.py -qpasses locally.Closes #1303
🤖 Generated with Claude Code